

function Check_onclick(targetForm)//return a string about the IDs which have been selected
{
   var controlIndex;
   var element;
   //var numberOfControls = document.viewForm.length;

   var numberOfControls = targetForm.length;
   //alert("aaaaaaaaaaaaaaaaaa");
   var compSpec = "'";//document.viewForm[0].value;

	   for (controlIndex = 1; controlIndex < numberOfControls; controlIndex++)
	   {
		  //element = document.viewForm[controlIndex];
		  element = targetForm[controlIndex];
		  if (element.type == "checkbox")
		  {
			 if (element.checked == true)
			 {
				compSpec = compSpec +"'" + element.value +"'," ;
				//alert(compSpec);
			 }
		  }
	   }
	var iStrLength = compSpec.length;
	var result = compSpec.substr(1,iStrLength - 2);
	//alert(result);

    //viewForm.SelectedId.value = result;
	targetForm.SelectedId.value = result;
    //alert(targetForm.SelectedId.value);
}

function Check_All(targetForm)
{
   var controlIndex;
   var element;
   var numberOfControls = targetForm.length;
   //var numberOfControls = document.viewForm.length;
   for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
   {
	  //element = document.viewForm[controlIndex];
	  element = targetForm[controlIndex];
	  if (element.type == "checkbox")
	  {
		element.checked = true;
	  }
   }
   //this.Check_onclick();
}

function CancelCheckAll(targetForm)
{
   var controlIndex;
   var element;
   var numberOfControls = targetForm.length;
   //var numberOfControls = document.viewForm.length;
   for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
   {
	  //element = document.viewForm[controlIndex];
	  element = targetForm[controlIndex];
	  if (element.type == "checkbox")
	  {
		element.checked = false;
	  }
   }
   //viewForm.SelectedId.value = "";
}
function ReverseSelect(targetForm)
{
   var controlIndex;
   var element;
   var numberOfControls = targetForm.length;
   //var numberOfControls = document.viewForm.length;
   for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
   {
	  //element = document.viewForm[controlIndex];
	  element = targetForm[controlIndex];
	  if (element.type == "checkbox")
	  {
		if (element.checked == false)
			element.checked = true;
		else
			element.checked = false;
	  }
   }
	//this.Check_onclick();
}
function checkItemsold(targetForm,theAction)
{
    varCollection = "";
    varUserID = "";
    var alertWorld;
    var controlIndex;
    var element;
    var numberOfControls = targetForm.length;
    var objSel = document.all("sysid");
    //var userId = document.all("fuheren");
    if(undefined!=objSel.length){
    	var recodeSize = objSel.length;
    	for(var i=0;i<recodeSize;i++){
      		if (objSel[i].checked == true)
      		{
      		if (varCollection=="") varCollection = objSel[i].value;
      		else varCollection = varCollection + "," + objSel[i].value;
      		//if (varUserID =="") varUserID = userId[i].value;
      		//else varUserID = varUserID + "," + userId[i].value;
      		}
    	}
    }else{
      varCollection = objSel.value;
      //varUserID = userId.value;
    }
	if(theAction=="delete"){
		alertWorld="????";
	}else if(theAction=="submit"){
		alertWorld="????";
	}else if(theAction=="audit"){
		alertWorld="????";
	}else if(theAction=="instock"){
		alertWorld="????";
	}else if(theAction=="unstock"){
		alertWorld="??????";
	}else if(theAction=="rushuse"){
		alertWorld="????????";
	}else{
		alertWorld="????";
	}

	if (varCollection == "")
	{
		alert("??????????"+ alertWorld +"??");
		return;
	}
	if (!confirm('??????'+ alertWorld +'??????????????????')) return;
	else {
		document.checkForm.action.value = theAction;
		document.checkForm.collection.value = varCollection;
        //document.checkForm.userID.value = varUserID;
		document.checkForm.submit();
	}
}
function checkItems(targetForm,theAction)
{
	varCollection = "";
    var alertWorld;
    var controlIndex;
    var element;
    var numberOfControls = targetForm.length;
   //var numberOfControls = document.viewForm.length;
	if(theAction=="delete"){
		alertWorld="????";
	}else if(theAction=="submit"){
		alertWorld="????";
	}else if(theAction=="audit"){
		alertWorld="????";
	}else if(theAction=="instock"){
		alertWorld="????";
	}else if(theAction=="unstock"){
		alertWorld="??????";
	}else if(theAction=="rushuse"){
		alertWorld="????????";
	}else{
		alertWorld="????";
	}
    for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
    {
	  //element = document.viewForm[controlIndex];
	  element = targetForm[controlIndex];
	  if (element.type == "checkbox")
	  {
			if (element.checked == true)
			{
				if (varCollection=="") varCollection = element.value;
				else varCollection = varCollection + "," + element.value
			}
	  }
	  if (element.type == "radio")
	  {
			if (element.checked == true)
			{
				varCollection = element.value;
			}
	  }
    }
	if (varCollection == "") 
	{
		alert("??????????"+ alertWorld +"??");
		return;
	}
	if (!confirm('??????'+ alertWorld +'??????????????????')) return;
	else {
		document.checkForm.action.value = theAction;
		document.checkForm.collection.value = varCollection;
		document.checkForm.submit();
	}
}
function checkItemsForAuth(targetForm,theAction,userInputID)
{
    varCollection = "";
    varUserID = "";
    var alertWorld;
    var controlIndex;
    var element;
    var numberOfControls = targetForm.length;
    var objSel = document.all("sysid");
    var userId = document.all(userInputID);
    var recodeSize = objSel.length;

          if (varCollection=="") varCollection = objSel.value;
          if (varUserID =="") varUserID = userId.value;


	if(theAction=="audit"){
		alertWorld="????";
	}
	if (varCollection == "")
	{
		alert("??????????"+ alertWorld +"??");
		return;
	}
	if (!confirm('??????'+ alertWorld +'??????????????????')) return;
	else {
		document.checkForm.action.value = theAction;
		document.checkForm.collection.value = varCollection;
                document.checkForm.userID.value = varUserID;
		document.checkForm.submit();
	}
}
function selectAll(formName,elementName,mode){
	var elements = document.getElementById(formName).elements;
	for (var i=0; i<elements.length; i++){
		if ((elements[i].name).indexOf(elementName) != -1) {
			switch (mode){
				case "A": // ????
					elements[i].checked = true;
					break
				case "N": // ????
					elements[i].checked = false;
					break
				case "R": // ????
					if (elements[i].checked == true)
						elements[i].checked = false;
					else
						elements[i].checked = true;
					break;
			}
		}
	}
}
function printDoc(){
  var printDiv = document.getElementById("printDiv");
  document.all.innerHTML = printDiv.innerHTML;
  window.print();
}
function gotoPage(thePage)
{
	var thePageNum = document.getElementById("thepagenum");
	thePageNum.value=thePage;
	//alert(thePageNum.value);
	document.jumpPage.submit();
}

function  transformView()  {
	var  tableElements  =  document.getElementsByTagName('table')  ;
	var  table  =  tableElements[1]  ;
	//table.width  =  '100%'  ;
	table.cellSpacing  =  '0'  ;
	headers  =  table.getElementsByTagName("th")  ;
	for(  i  =  0;  i  <  headers.length;  i++)  {
	headers[i].bgColor  =""  ;
	}

	rows  =  table.getElementsByTagName("tr")  ;
	var  counter  =  0
	for(  i  =  1;  i  <  rows.length;  i++)  {
	rows[i].bgColor  =  (i  %  2  ?  '#efefef'  :  '')  ;
	}
}
